package com.huaxia.dao.promotion;

import com.huaxia.pojo.promotion.BranchSBC;

import org.apache.ibatis.annotations.Select;


import java.util.List;

/**
 * @author wangli 爱我华夏，爱我中华！
 * @date 2020/06/09 14:31
 */


public interface BranchSbcMapper {

    @Select("\n" +
            "select b.branchsname,b.branchNumSBC,a.branchQuarterNumSBC,round(decode(b.branchNumSBC,0,0,a.branchQuarterNumSBC*100/b.branchNumSBC),1)branchYieldSBC from\n" +
            "            (select sb.branchsname,NVL(a.num,0)branchQuarterNumSBC from\n" +
            "            (select t.branchcode,count(t.branchcode)num from D_AGENT_PROVINCE_YX2 t where t.agentgrade='SBC' and to_char(t.startdate,'q')=to_char(sysdate,'q') and t.agentstate='在职' group by t.branchcode)a right join SD_BRANCH sb on sb.branchcode=a.branchcode\n" +
            "        )a,\n" +
            "                (select sb.branchsname,NVL(a.num,0)branchNumSBC from\n" +
            "            (select t.branchcode,count(t.branchcode)num from D_AGENT_PROVINCE_YX2 t where t.agentgrade='SBC' and t.agentstate='在职' group by t.branchcode)a right join SD_BRANCH sb on sb.branchcode=a.branchcode\n" +
            "        )b where a.branchsname=b.branchsname ORDER BY a.branchQuarterNumSBC DESC")
    List<BranchSBC> getBranchSBC();
}
